package cn.jbit.supermarker.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
//读取配置文件的工具类
public class ConfigManager {
	private static ConfigManager configManager;
	private static Properties properties;
	//在构造工具类时，进行配置文件的读取
	private ConfigManager(){
		String configFile="database.properties";
		properties=new Properties();
		InputStream is=ConfigManager.class.getClassLoader().getResourceAsStream(configFile);
		try {
			properties.load(is);
			is.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	//设置单例模式设置实例化的个数
	public static ConfigManager getInstance(){
		if(configManager==null){
			configManager=new ConfigManager();
		}
		return configManager;
	}
	public String getString(String key){
		return properties.getProperty(key);
	}
	
}
